//
//  AudioTypeCollectionViewCell.m
//  AudioBook_A
//
//  Created by Sansan on 15/4/16.
//  Copyright (c) 2015年 Sansan. All rights reserved.
//

#import "AudioTypeCollectionViewCell.h"

@implementation AudioTypeCollectionViewCell

- (void)dealloc
{
    [_audioTypeImageView release];
    [_audioTypenameLabel release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self creatView];
    }
    return self;
}

- (void)creatView
{
    self.contentView.backgroundColor = [UIColor whiteColor];
    self.audioTypeImageView = [[UIImageView alloc] initWithFrame:CGRectMake(5, 5, 100, 80)];
    [self.contentView addSubview:self.audioTypeImageView];
    
    self.audioTypenameLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 83, 100, 30)];
    //Label 文字居中对齐
    self.audioTypenameLabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.audioTypenameLabel];
    
    [_audioTypenameLabel release];
    [_audioTypeImageView release];
}


// 加载图片
- (void)setModel:(AudioTypeModel *)model
{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    
    self.audioTypenameLabel.text = _model.tname;
    self.audioTypenameLabel.font = [UIFont systemFontOfSize:14];
    
    [self.audioTypeImageView sd_setImageWithURL:[NSURL URLWithString:_model.cover_path] placeholderImage:[UIImage imageNamed:@"listen.jpg"]];
    
}

@end
